From 5ab29fa1ca3c347e21b7dc865ae971c10758d7b0 Mon Sep 17 00:00:00 2001
From: Gautier Portet <gautier.portet@telespazio.com>
Date: Mon, 25 Oct 2021 14:43:53 +0200
Subject: [PATCH] Prevent crash when duration is not known or zero

Closes lp:1948670, thank Richard.
---
 soundconverter/gstreamer/converter.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/soundconverter/gstreamer/converter.py b/soundconverter/gstreamer/converter.py
index 0789e54..9e97385 100644
--- a/soundconverter/gstreamer/converter.py
+++ b/soundconverter/gstreamer/converter.py
@@ -260,7 +260,7 @@ def get_progress(self):
             return 0, duration
 
         position = self._query_position()
-        progress = position / duration
+        progress = position / duration if duration else 0
         progress = min(max(progress, 0.0), 1.0)
         return progress, duration
 
